package pl.edu.agh.uhm.core;

import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;

import pl.edu.agh.uhm.discoverer.Hypervisor;

public class AdapterFactory implements IAdapterFactory{

	  private IWorkbenchAdapter hypervisorAdapter = new IWorkbenchAdapter() {
		    public Object getParent(Object o) {
		    	 return new Object[0];
		    }
		    public String getLabel(Object o) {
		      Hypervisor h=(Hypervisor)o;
		      return h.getName(); 
		    }
		    public ImageDescriptor getImageDescriptor(Object object) {
		      // to be filled in soon!
		      return null;
		    }

		    public Object[] getChildren(Object o) {
		      return new Object[0];
		    }
		  };


	
	@Override
	public Object getAdapter(Object adaptableObject, Class adapterType) {
		
		if(adapterType == IWorkbenchAdapter.class &&
		         adaptableObject instanceof Hypervisor)
			return hypervisorAdapter;
		else
			return null;
	}

	@Override
	public Class[] getAdapterList() {
		return new Class[] {IWorkbenchAdapter.class};
	}

}
